<!DOCTYPE html>
<%@ page language="java" pageEncoding="UTF-8"%>
<html class="root61" style="background-color: #fff;">
<head>
<%@include file="/views/common/include/taglib.jsp"%>
<%@include file="/views/common/include/head.jsp"%>
<link type="text/css" rel="stylesheet" href="${ctx}/css/dlifestyle/table.css" />

</head>
<body class="body" style="margin: 0px;background-color: #fff;overflow-y:scroll;">
	<%@include file="/views/common/header.jsp"%>
	<section class="short-cut">
		<section id="left" style="margin-top:142px;position:relative;">
			<!-- 二三级菜单区域 -->
		</section>
		<section id="main" class="main" style="margin-top:40px;margin-bottom: 50px;margin-left:240px;overflow: hidden;">
			<!-- 内容区域 -->
		</section>
	</section>
	<%@include file="/views/common/footer.jsp"%>
	<script type="text/javascript">
	
		function homePageShowOrder(menuId, itemId, url) {
			$("#left").show();
			$("#left").load(
					getUrl('${ctx}/left?menuId=' + menuId),
					function(response, status, xhr) {
						if (status != 'success') {
							$("#left").load(getUrl('${ctx}/leftError?menuId=' + menuId));
						} else {
							$("#main").html("");
							clickSecondMenu(itemId, url);
						}
	
						//更换一级菜单选中状态
						$("li[name='firstMenu']").each(function() {
							$(this).removeClass("admin_nav_ul_li_active");
						});
						$("#firstMenu" + menuId).addClass(
								"admin_nav_ul_li_active");
					});
		}
		
		function homePageShowDetail(menuId, itemId, url,detaiId) {
            $("#left").show();
            $("#left").load(
                    getUrl('${ctx}/left?menuId=' + menuId),
                    function(response, status, xhr) {
                        if (status != 'success') {
                            $("#left").load(getUrl('${ctx}/leftError?menuId=' + menuId));
                        } else {
                            $("#main").html("");
                            //clickSecondMenu(itemId, url);
                            loadContent("/noticeInfo/noticeInfoDetail?id=" + detaiId);
                        }
    
                        //更换一级菜单选中状态
                        $("li[name='firstMenu']").each(function() {
                            $(this).removeClass("admin_nav_ul_li_active");
                        });
                        $("#firstMenu" + menuId).addClass(
                                "admin_nav_ul_li_active");
                    });
          //更换二级菜单选中状态
            $("li[name='secondMenu']").each(function() {
                $(this).removeClass("second-menu-active");
            });
            $("#secondMenu" + itemId).addClass("second-menu-active");

            //重置三级菜单状态
            $("li[name='thirdMenu']").each(function() {
                $(this).removeClass("three-menu-active");
            });

            $("li[name='thirdMenuSpan']").each(function() {
                $(this).removeClass("three-menu-selected-point-active");
            });

            $("img[name='thirdMenuImg']").each(function() {
                $(this).hide();
            });
            $("ul[name='third']").each(function() {
                $(this).hide();
            });

            $("img[name='thirdimg']").each(function() {
                $(this).attr('src', "${ctx}/images/system/more_close.png");
            });
        }

	
		/**加载二三级菜单区域*/
		function loadLeft(menuId) {
			$("#left").show();
			$("#left").load(
					getUrl('${ctx}/left?menuId=' + menuId),
					function(response, status, xhr) {
						if (status != 'success') {
							$("#left").load(getUrl('${ctx}/leftError?menuId=' + menuId));
						} else {
							$.get(getUrl("${ctx}/content?menuId=" + menuId), function(
									result) {
								result = JSON.parse(result);
								if (result.success && result.obj != null) {
									var menu = result.obj;
									if (menu.menuLevel == 1){
										$("#main").html("");
										$("#main").load(getUrl('${ctx}' + menu.locationURL));
										$("#left").hide();
									}
									else if (menu.menuLevel == 2) {
										$("#main").html("");
										clickSecondMenu(menu.id,
												menu.locationURL);
									} else {
										$("#main").html("");
										clickThirdMenu(menu.parentId, menu.id,
												menu.locationURL);
										clickShowOrHide(menu.parentId);
									}
								} else {
									$("#left").load(getUrl('${ctx}/leftError?menuId=' + menuId));
								}
							});
						}

						//更换一级菜单选中状态
						$("li[name='firstMenu']").each(function() {
							$(this).removeClass("admin_nav_ul_li_active");
						});
						$("#firstMenu" + menuId).addClass(
								"admin_nav_ul_li_active");
					});
		}

		loadLeft('${sessionScope.user_login.menu.id}');
		
		/**加载内容区域*/
		function loadContent(url) {
			var index = layer.load(1);
			$("#main").html("");
			$("#main").load(getUrl('${ctx}' + encodeURI(url)), function(response, status, xhr) {
				if (status != 'success') {
					$("#main").load(getUrl('${ctx}/contentError?url=' + url));
				}else{
					$('html, body').animate({scrollTop:0}, 'slow');//页面滑动到顶部
				}
				
				layer.close(index);
			});
		}
		
		/**加载内容区域，二级菜单点击*/
		function clickSecondMenu(id, url) {
			var index = layer.load(1);
			$("#main").load(getUrl('${ctx}' + url), function(response, status, xhr) {
				if (status != 'success') {
					$("#main").load(getUrl('${ctx}/contentError?url=' + url));
				}else{
					$('html, body').animate({scrollTop:0}, 'slow');//页面滑动到顶部
				}

				layer.close(index);

				//更换二级菜单选中状态
				$("li[name='secondMenu']").each(function() {
					$(this).removeClass("second-menu-active");
				});
				$("#secondMenu" + id).addClass("second-menu-active");

				//重置三级菜单状态
				$("li[name='thirdMenu']").each(function() {
					$(this).removeClass("three-menu-active");
				});

				$("li[name='thirdMenuSpan']").each(function() {
					$(this).removeClass("three-menu-selected-point-active");
				});

				$("img[name='thirdMenuImg']").each(function() {
					$(this).hide();
				});
				$("ul[name='third']").each(function() {
					$(this).hide();
				});

				$("img[name='thirdimg']").each(function() {
					$(this).attr('src', "${ctx}/images/system/more_close.png");
				});
			});
		}

		/**加载内容区域，三级菜单点击*/
		function clickThirdMenu(parent, id, url) {
			var index = layer.load(1);
			$("#main")
					.load(getUrl('${ctx}' + url),
							function(response, status, xhr) {
								if (status != 'success') {
									$("#main").load(getUrl('${ctx}/contentError?url=' + url));
								}else{
									$('html, body').animate({scrollTop:0}, 'slow');
								}
								
								layer.close(index);

								//更换三级菜单选中状态
								$("li[name='thirdMenu']").each(function() {
									$(this).removeClass("three-menu-active");
								});
								$("#thirdMenu" + id).addClass(
										"three-menu-active");

								$("li[name='thirdMenuSpan']")
										.each(
												function() {
													$(this)
															.removeClass(
																	"three-menu-selected-point-active");
												});
								$("#thirdMenuSpan" + id).addClass(
										"three-menu-selected-point-active");

								$("img[name='thirdMenuImg']").each(function() {
									$(this).hide();
								});
								$("#thirdMenuImg" + id).show();

								//更换二级菜单选中状态
								$("li[name='secondMenu']").each(function() {
									$(this).removeClass("second-menu-active");
								});
								$("#secondMenu" + parent).addClass(
										"second-menu-active");
							});

		}

		/**三级菜单显示或隐藏*/
		function clickShowOrHide(id) {
			if ($("#third" + id).is(":hidden")) {
				$("#third" + id).show();
				$("#thirdimg" + id)
						.attr('src', "${ctx}/images/system/more.png");
			} else {
				$("#third" + id).hide();
				$("#thirdimg" + id).attr('src',
						"${ctx}/images/system/more_close.png");
			}
		}
		
		/**加时间戳参数，防止IE下缓存不刷新*/
		function getUrl(url){
			if(url.indexOf('?') > 0){
				return url + "&timestamp=" + Date.parse(new Date());
			}
			
			return url + "?timestamp=" + Date.parse(new Date());
		}
	</script>
</body>
</html>